<template>
  <div class="nyr bg-ff">
    <div class="nyr_center">
      <van-datetime-picker
        v-model="currentDate"
        type="datetime"
        :min-date="minDate"
        :max-date="maxDate"
        @confirm="sure"
      />
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      minDate: new Date(1900, 1, 1),
      maxDate: new Date(2300, 12, 31),
      currentDate: new Date()
    };
  },
  mounted() {document.querySelector('html').style.backgroundColor = "#ffffff";},
  methods: {
    sure(e) {
      let type = this.$route.params.type;
      let value =
        e.getFullYear() +
        "-" +
        (e.getMonth() + 1) +
        "-" +
        e.getDate() +
        " " +
        e.getHours() +
        ":" +
        e.getMinutes() +
        ":" +
        e.getSeconds();
      if (!value && this.$route.params.notnull == 1) {
        this.$toast("请选择完整~");
        return false;
      }
      this.$axios.post( "/wap/personal/editUserInfo", {
        token: window.localStorage.getItem("token"),
        key: type,
        value: value
      }).then(res => {
        this.$toast(res.data.msg);
        if (res.data.code == 0) {
          this.$router.go(-1);
        }
      });
    }
  }
};
</script>

<style>
html {
  background: white;
}
</style>

<style>
.nyr .van-picker__columns {
  position: fixed;
  width: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.nyr .van-picker__toolbar {
  position: fixed;
  width: 100%;
  bottom: 0.5rem;
  z-index: 999;
  width: 100%;
}
.nyr .van-picker__cancel {
  display: none;
}
.nyr .van-picker__confirm {
  width: 100%;
  background: #ff0000;
  color: white;
  text-align: center;
  letter-spacing: 0.1rem;
  border-radius: 0.1rem;
}
</style>